/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Mensajes;

/**
 *
 * @author Lino
 */
public class ValidadorEnvioHL7 {

    public static boolean validarMsj(String tipo, String HL7) {
        try {

            String[] msj = HL7.split("\\|");
            if (tipo.equals("OML^021")) {
                if (msj.length != 66) {
                    return false;
                } else {
                    if (Integer.parseInt(msj[9]) <= 0) {
                        return false;
                    }
                    String[] obr = HL7.split("OBR\\|")[1].split("\\|");
                    if (Integer.parseInt(obr[1].split(";")[1]) <= 0) {
                        return false;
                    }
                    if (Integer.parseInt(obr[1].split(";")[2]) <= 0) {
                        return false;
                    }
                    if (Integer.parseInt(obr[3].split("-")[0]) <= 0) {
                        return false;
                    }
                }
            }
            return true;

        } catch (Exception e) {
        }

        return false;
    }
}
